<template>
<div id="titleCharts" style="width:100%;height:50px">

</div>
</template>

<script>
import echarts from "echarts";
export default {
    data() {
        return {}
    },
    watch: {
        options: {
            handler(newVal, oldVal) {
                this.draw();
            },
            deep: true //对象内部属性的监听，关键。
        }
    },
    props: {
        options: {},
    },
    methods: {
        draw() {
            let titleCharts = echarts.init(document.getElementById('titleCharts'));
            titleCharts.setOption(this.options);
            window.addEventListener("resize", function () {
                titleCharts.resize();
            });
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.draw();
        });
    }
}
</script>
